#include <bits/stdc++.h>
#define ld long double
#define rep(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define m_p make_pair
#define pii pair<int,int>
#define fr first
#define sc second
using namespace std;

const int maxn=100005;
int n,m,L,V;
int d[maxn],v[maxn],a[maxn];
int p[maxn];

bool cmp(pii x,pii y){
    return x.sc<y.sc;
}
int solve(vector<pii> &vec){
    sort(vec.begin(),vec.end(),cmp);
    int mx=-1;
    int ans=0;
    rep(i,(int)vec.size()){
        if(vec[i].fr>mx){
            mx=vec[i].sc;
            ans++;
        }
    }
    return ans;
}

int getpos1(int x,int A,int cur){
    int l=0,r=m,mid;
    while(l<r){
        mid=(l+r)/2;
        if(2*A*(p[mid]-cur)>x) r=mid;
        else l=mid+1;
    }
    return l;
}
int getpos2(int x,int A,int cur){
    int l=0,r=m,mid;
    while(l<r){
        mid=(l+r)/2;
        if(2*A*(p[mid]-cur)>x) l=mid+1;
        else r=mid;
    }
    return l-1;
}

void tc(){
    cin>>n>>m>>L>>V;
    rep(i,n) cin>>d[i]>>v[i]>>a[i];
    rep(i,m) cin>>p[i];
    vector<pii> vec;
    rep(i,n){
        if(a[i]==0){
            if(v[i]>V){
                int pos=lower_bound(p,p+m,d[i])-p;
                if(pos<m) vec.pb(m_p(pos,m-1));
            }
        }
        if(a[i]>0){
            if(v[i]>V){
                int pos=lower_bound(p,p+m,d[i])-p;
                if(pos<m) vec.pb(m_p(pos,m-1));
            }
            else{
                // ld dis=d[i]+1.0*(V*V-v[i]*v[i])/2/a[i];
                int pos=getpos1((V*V-v[i]*v[i]),a[i],d[i]);
                if(pos<m) vec.pb(m_p(pos,m-1));
            }
        }
        if(a[i]<0){
            if(v[i]>V){
                int pos1=lower_bound(p,p+m,d[i])-p;
                // ld dis=d[i]+1.0*(V*V-v[i]*v[i])/2/a[i];
                int pos2=getpos2((V*V-v[i]*v[i]),a[i],d[i]);
                if(pos1<=pos2){
                    vec.pb(m_p(pos1,pos2));
                    // cout<<i<<' '<<pos1<<' '<<pos2<<endl;
                }
            }
        }
    }
    // rep(i,(int)vec.size()){
    //     cout<<vec[i].fr<<' '<<vec[i].sc<<endl;
    // }
    cout<<(int)vec.size()<<' ';
    cout<<m-solve(vec)<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    int T;
    cin>>T;
    while(T--){
        tc();
    }
    return 0;
}